{% if ansible_host is not defined or ansible_host == 'localhost' %}
{% set ssh_host = inventory_hostname %}
{% else %}
{% set ssh_host = ansible_host %}
{% endif %}
{% if ansible_private_key_file is defined %}
{% set ssh_key_arg = " -i " + ansible_private_key_file + " " %}
{% else %}
{% set ssh_key_arg = "" %}
{% endif %}
{% set proxycommand="ssh -o UserKnownHostsFile=/dev/null "
    + "-o StrictHostKeyChecking=no -o ConnectTimeout=60 "
    + ssh_key_arg
    + ssh_user + '@' + ssh_host + " -W " + undercloud_ip + ":22" %}

Host undercloud-root
    ProxyCommand {{proxycommand}}
    IdentityFile {{ local_working_dir }}/id_rsa_undercloud
    User root
    StrictHostKeyChecking no
    UserKnownHostsFile=/dev/null

Host undercloud
    ProxyCommand {{proxycommand}}
    IdentityFile {{ local_working_dir }}/id_rsa_undercloud
    User {{ undercloud_user }}
    StrictHostKeyChecking no
    UserKnownHostsFile=/dev/null

Host undercloud-from-virthost
    Hostname {{ undercloud_ip }}
    IdentityFile ~/.ssh/id_rsa
    IdentitiesOnly yes
    User root
    StrictHostKeyChecking no
